package com.action;

import com.dao.BooksDao;
import com.entity.Books;
import com.opensymphony.xwork2.ActionSupport;

import java.util.ArrayList;
import java.util.List;

public class BooksAction extends ActionSupport {

    private Integer id;
    private Books books;
    private List<Books> booksList = new ArrayList<>();
    private BooksDao booksDao = new BooksDao();

    public String addBooks() {
        if (books == null) {
            return INPUT;
        }
        booksDao.save(books);
        return SUCCESS;
    }

    public String listBooks() {
        booksList = booksDao.searchList();
        return SUCCESS;
    }

    public String viewDetails() {
        books = booksDao.searchById(id);
        return SUCCESS;
    }

    public String addCart() {
        return SUCCESS;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Books getBooks() {
        return books;
    }

    public void setBooks(Books books) {
        this.books = books;
    }

    public List<Books> getBooksList() {
        return booksList;
    }

    public void setBooksList(List<Books> booksList) {
        this.booksList = booksList;
    }
}
